package auth

import (
	mgr "hermestrans/internal/portal/manager"
	"sync"
)

type Auth struct {
	mysql *mgr.MysqlMgr
	redis *mgr.RedisMgr
}

var (
	auth    Auth
	authIns sync.Once
)

func NewAuth(mysql *mgr.MysqlMgr, redis *mgr.RedisMgr) (*Auth, error) {
	var (
		err  error
		auth *Auth
	)
	authIns.Do(func() {
		auth = &Auth{
			mysql: mysql,
			redis: redis,
		}
	})
	return auth, err
}

// 通过用户获取所在组
func (a Auth) GetGroupByUser(username string) ([]string, error) {
	var (
		privs []string
		err   error
	)
	return privs, err
}

// 验证权限
func (a Auth) Check(sub, obj, act string) {

}

// 添加用户权限
func (a Auth) AddGroups(ptype string, rules [][]string) {

}

//删除用户组获取权限
//更新用户所属于的组
//指定用户组的权限
